package com.cc.blog.web.controller;

import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.Result;
import com.cc.blog.web.domain.dto.FindArticleDetailReqDTO;
import com.cc.blog.web.domain.dto.FindIndexArticlePageListReqDTO;
import com.cc.blog.web.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章
 * @Author cc
 * @Date 2024/7/12 10:02
 */
@RestController
@RequestMapping("/article")
@Api(tags = "文章")
@AllArgsConstructor
public class ArticleController {

    private final ArticleService articleService;

    @PostMapping("/list")
    @ApiOperation(value = "获取首页文章分页数据")
    @ApiOperationLog(description = "获取首页文章分页数据")
    public Result findArticlePageList(@RequestBody FindIndexArticlePageListReqDTO findIndexArticlePageListReqDTO) {
        return articleService.findArticlePageList(findIndexArticlePageListReqDTO);
    }

    @PostMapping("/detail")
    @ApiOperation(value = "获取文章详情")
    @ApiOperationLog(description = "获取文章详情")
    public Result findArticleDetail(@RequestBody FindArticleDetailReqDTO findArticleDetailReqDTO) {
        return articleService.findArticleDetail(findArticleDetailReqDTO);
    }
}
